<template>
  <div class="printForm">
    <div class="area-header">
      <span class="area-header-title">{{ $t('申请单') }}</span>
    </div>
    <table class="printTable">
      <tr>
        <td class="tit">{{ $t('申请标题') }}</td>
        <td colspan="3"><span :style="{ color: mark.actTitleMark ? '#e6a23c' : '' }">{{ form.actTitle }}</span></td>
      </tr>
      <tr>
        <td class="tit">{{ $t('经办人') }}</td>
        <td>
          <span :style="{ color: mark.applyUserIdMark ? '#e6a23c' : '' }">{{ form.userName }}</span>
        </td>
        <td class="tit">{{ $t('申请时间') }}</td>
        <td><span :style="{ color: mark.applyTimeMark ? '#e6a23c' : '' }">{{ parseTime(form.applyTime) }}</span></td>
      </tr>
      <tr>
        <td class="tit">{{ $t('经办部门') }}</td>
        <td>
          <span :style="{ color: mark.deptIdMark ? '#e6a23c' : '' }">{{ form.deptName }}</span>
        </td>
        <td class="tit">{{ $t('合同编码') }}</td>
        <td><span :style="{ color: mark.contractNoMark ? '#e6a23c' : '' }">{{ parseTime(form.contractNo) }}</span></td>
      </tr>
      <tr>
        <td class="tit">{{ $t('合同名称') }}</td>
        <td>
          <span :style="{ color: mark.nameMark ? '#e6a23c' : '' }">{{ form.name }}</span>
        </td>
        <td class="tit">{{ $t('合同类型') }}</td>
        <td>
          <span :class="mark.typeMark ? 'markDifferent' : ''">
            {{ selectDictLabel(getTypeDict, form.type) }}
          </span>
        </td>
      </tr>
      <tr>
        <td class="tit">{{ $t('合同对方名称') }}</td>
        <td>
          <span :style="{ color: mark.companyMark ? '#e6a23c' : '' }">{{ form.company }}</span>
        </td>
        <td class="tit">{{ $t('合同到期日') }}</td>
        <td><span :style="{ color: mark.expirationDateMark ? '#e6a23c' : '' }">{{ parseTime(form.expirationDate) }}</span></td>
      </tr>
      <tr>
        <td class="tit">{{ $t('是否自动续签') }}</td>
        <td>
          <span :style="{ color: mark.automaticRenewalMark ? '#e6a23c' : '' }">{{ formatSeal(form.automaticRenewal) }}</span>
        </td>
        <td class="tit">{{ $t('是否为补充协议') }}</td>
        <td><span :style="{ color: mark.supplementaryMark ? '#e6a23c' : '' }">{{ formatSeal(form.supplementary) }}</span></td>
      </tr>
      <tr>
        <td class="tit">{{ $t('收付款类型') }}</td>
        <td>
          <span :style="{ color: mark.isPaymentMark ? '#e6a23c' : '' }">
            {{ formatPayment(form.isPayment) }}
          </span>
        </td>
        <td class="tit"> {{ $t('合同金额') }}{{ $t('金额单位') }} </td>
        <td>
          <span :style="{ color: mark.moneyMark ? '#e6a23c' : '' }">
            {{ moneyFormat(form.money, 'w') }}
          </span>
        </td>
      </tr>
      <tr v-if="isShowDeal === 'hidden'">
        <td class="tit">  {{ $t('项目名称') }}   </td>
        <td colspan="3">
          {{ form.dealName }}
        </td>
      </tr>
      <tr v-if="form.isPayment === 'collection' || form.isPayment === 'payment'">
        <td>{{ $t('币种') }}</td>
        <td>
          <dictSelect
            v-model="form.currency"
            :is-echo="true"
            dictionary="currency"
            :class="mark.currencyMark ? 'markDifferent' : ''"
          />
        </td>
        <td v-if="form.isPayment === 'collection' || form.isPayment === 'payment'" class="tit">{{ $t('总股本(万股)') }}</td>
        <td v-if="form.isPayment === 'collection' || form.isPayment === 'payment'">
          <span :style="{ color: mark.totalAfterInvestmentMark ? '#e6a23c' : '' }">
            {{ moneyFormat(form.totalAfterInvestment, 'w') }}
          </span>
        </td>
      </tr>
      <tr>
        <td class="tit">
          {{ $t('法审编号') }}
        </td>
        <td colspan="3" :style="{ color: mark.legalReviewCodeMark ? '#e6a23c' : '' }">
          {{ form.legalReviewCode }}
        </td>
      </tr>
      <tr>
        <td class="tit">{{ $t('法审意见') }}</td>
        <td colspan="3">
          <span :style="{ color: mark.legalReviewOpinionsMark ? '#e6a23c' : '' }">
            {{ form.legalReviewOpinions }}
          </span>
        </td>
      </tr>
      <tr>
        <td class="tit">{{ $t('法审意见落实情况') }}</td>
        <td colspan="3">
          <span :style="{ color: mark.implementationOfOpinionsMark ? '#e6a23c' : '' }">
            {{ form.implementationOfOpinions }}
          </span>
        </td>
      </tr>
      <tr>
        <td class="tit">{{ $t('合同摘要') }}</td>
        <td colspan="3">
          <span :style="{ color: mark.abstractsMark ? '#e6a23c' : '' }">
            {{ form.abstracts }}
          </span>
        </td>
      </tr>
      <tr>
        <td class="tit">{{ $t('特殊条款') }}</td>
        <td colspan="3">
          <span :style="{ color: mark.abstractsMark ? '#e6a23c' : '' }">
            {{ form.specialTerms }}
          </span>
        </td>
      </tr>
    </table>

    <!--用印明细-->
    <div v-show="form.oaSealDetailList && form.oaSealDetailList.length > 0" style="margin-bottom: 20px;">
      <div class="area-header">
        <span class="area-header-title">{{ $t('用印明细') }}</span>
      </div>
      <table class="previewTable">
        <thead>
          <th>{{ $t('用印主体类型') }}</th>
          <th>{{ $t('用印主体') }}</th>
          <th>{{ $t('用印类型') }}</th>
          <th>{{ $t('备注') }}</th>
        </thead>
        <tbody>
          <tr v-for="(v, ind) in form.oaSealDetailList" :key="ind">
            <td>
              <dictSelect
                v-model="v.investMainType"
                :is-echo="true"
                dictionary="main_body_type"
                :class="sealMark[ind] !== undefined && sealMark[ind].investMainTypeMark ? 'markDifferent' : sealMarkId.includes(v.id) ? 'markDifferentNew' : ''"
              />
            </td>
            <td>
              <MainBodySelect
                v-model="v.investMain"
                :is-echo="true"
                :parameters="v.investMainType"
                :class="sealMark[ind] !== undefined && sealMark[ind].investMainMark ? 'markDifferent' : sealMarkId.includes(v.id) ? 'markDifferentNew' : ''"
              />
            </td>
            <td>
              <span :class="sealMark[ind] !== undefined && sealMark[ind].sealTypeMark ? 'selectMoreMark' : sealMarkId.includes(v.id) ? 'selectMoreMarkNew' : ''">
                {{ selectDictLabels(sealTypeDict, v.sealType) }}
              </span>
            </td>
            <td>
              <span :style="{ color: sealMark[ind] !== undefined && sealMark[ind].remarkMark ? '#e6a23c' : sealMarkId.includes(v.id) ? '#8bc34a' : '' }">
                {{ v.remark }}
              </span>
            </td>
          </tr>
        </tbody>
      </table>

    </div>
    <!-- 签约 主体 -->
    <div v-if="form.dealContractPaymentSpoList && form.dealContractPaymentSpoList.length > 0" style="margin-bottom: 20px;">
      <div class="area-header">
        <span class="area-header-title">{{ $t('签约主体') }}</span>
      </div>
      <table class="previewTable">
        <thead>
          <th>{{ $t('主体类型') }}</th>
          <th>{{ $t('主体名称') }}</th>
          <th v-if="isShowStake && form.type !== 'KZZTZXY' || (form.type === 'KZZXYTZ' && form.isPayment === 'no')">{{ $t('证券账号') }}</th>
          <th v-if="isShowStake && form.isPayment === 'payment' && !(form.type === 'KZZXYTZ' && form.isPayment === 'no')">{{ $t('投资金额') + $t('金额单位') }}</th>
          <th v-if="isShowStake && form.type !== 'KZZTZXY' || (form.type === 'KZZXYTZ' && form.isPayment === 'no')">{{ $t('本次新增持股数量(万股)') }}</th>
          <th v-if="isShowStake && form.type !== 'KZZTZXY' || (form.type === 'KZZXYTZ' && form.isPayment === 'no')">{{ $t('本次新增持股比例(%)') }}</th>
          <th v-if="(isShowStake || (form.type === 'KZZXYTZ' && form.isPayment === 'no')) && form.calculateShareholding && form.type !== 'KZZTZXY'">{{ $t('成本价(元)') }}</th>
          <th>{{ $t('备注') }}</th>
        </thead>
        <tbody>
          <tr v-for="(v, ind) in form.dealContractPaymentSpoList" :key="ind">
            <td>
              <dictSelect
                v-model="v.investType"
                :is-echo="true"
                dictionary="deal_investment_type"
                :class="investorMark[ind] !== undefined && investorMark[ind].investTypeMark ? 'markMain' : investorMarkId.includes(v.id) ? 'markDifferentNew' : ''"
              />
            </td>
            <td>
              <MainBodySelect
                v-model="v.investMain"
                :is-echo="true"
                :parameters="v.investType"
                :class="investorMark[ind] !== undefined && investorMark[ind].investMainMark ? 'markMain' : investorMarkId.includes(v.id) ? 'markDifferentNew' : ''"
              />
            </td>
            <td v-if="isShowStake && form.isPayment === 'payment' && !(form.type === 'KZZXYTZ' && form.isPayment === 'no')">
              <span :style="{ color: (investorMark[ind] !== undefined && investorMark[ind].securitiesAccountMark) ? '#e6a23c' : ((investorMarkId.includes(v.id)) ? '#8bc34a' : '') }">
                {{ moneyFormat(v.securitiesAccount, 'w') }}
              </span>
            </td>
            <td v-if="isShowStake && form.isPayment === 'payment' && !(form.type === 'KZZXYTZ' && form.isPayment === 'no')">
              <span :style="{ color: (investorMark[ind] !== undefined && investorMark[ind].investmentAmountMark) ? '#e6a23c' : ((investorMarkId.includes(v.id)) ? '#8bc34a' : '') }">
                {{ moneyFormat(v.investmentAmount, 'w') }}
              </span>
            </td>
            <td v-if="isShowStake && form.type !== 'KZZTZXY' || (form.type === 'KZZXYTZ' && form.isPayment === 'no')">
              <span :style="{ color: investorMark[ind] !== undefined && investorMark[ind].numberOfSharesMark ? '#e6a23c' : investorMarkId.includes(v.id) ? '#8bc34a' : '' }">
                {{ moneyFormat(v.numberOfShares, 'w') }}
              </span>
            </td>
            <td v-if="isShowStake && form.type !== 'KZZTZXY' || (form.type === 'KZZXYTZ' && form.isPayment === 'no')">
              <span :style="{ color: investorMark[ind] !== undefined && investorMark[ind].stakeMark ? '#e6a23c' : investorMarkId.includes(v.id) ? '#8bc34a' : '' }">
                {{ v.stake }}
              </span>
            </td>
            <td v-if="(isShowStake || (form.type === 'KZZXYTZ' && form.isPayment === 'no')) && form.calculateShareholding && form.type !== 'KZZTZXY'">
              <span :style="{ color: investorMark[ind] !== undefined && investorMark[ind].investorNumberOfSharesMark ? '#e6a23c' : investorMarkId.includes(v.id) ? '#8bc34a' : '' }">
                {{ moneyFormat(v.investorNumberOfShares, 'w') }}
              </span>
            </td>
            <td v-if="(isShowStake || (form.type === 'KZZXYTZ' && form.isPayment === 'no')) && form.calculateShareholding && form.type !== 'KZZTZXY'">
              <span :style="{ color: investorMark[ind] !== undefined && investorMark[ind].stakeMark ? '#e6a23c' : investorMarkId.includes(v.id) ? '#8bc34a' : '' }">
                {{ v.stake }}
              </span>
            </td>
            <td>
              <span :style="{ color: investorMark[ind] !== undefined && investorMark[ind].remarkMark ? '#e6a23c' : investorMarkId.includes(v.id) ? '#8bc34a' : '' }">
                {{ v.remark }}
              </span>
            </td>
          </tr>
        </tbody>
      </table>
    </div>

    <!-- 收款计划 -->
    <div v-if="form.dealContractPlanSpoList && form.dealContractPlanSpoList.length > 0" v-show="nameReceiptPayment === '付款' && (form.isPayment === 'payment')" style="margin-bottom: 20px;">
      <div class="area-header">
        <span class="area-header-title">{{ $t(nameReceiptPayment) }}{{ $t('计划') }}</span>
      </div>
      <table class="previewTable">
        <thead>
          <th>{{ $t('主体名称') }}</th>
          <th>{{ $t('预计') + $t(nameReceiptPayment) + $t('时间') }}</th>
          <th>{{ $t('预计付款金额') }} {{ $t('金额单位') }}</th>
          <th>{{ $t('备注') }}</th>
        </thead>
        <tbody>
          <tr v-for="(v, ind) in form.dealContractPlanSpoList" :key="ind">
            <td>
              <span :class="planMark !== null && planMark !== undefined && planMark[ind] !== undefined && planMark[ind].investIdMark ? 'markDifferent' : (planMarkId.includes(v.id) ? 'markDifferentNew' : '')">
                {{ v.investName }}
              </span>
            </td>
            <td>
              <span :style="{ color: planMark[ind] !== undefined && planMark[ind].paymentTimeMark ? '#e6a23c' : planMarkId.includes(v.id) ? '#8bc34a' : '' }">
                {{ parseTime(v.paymentTime) }}
              </span>
            </td>
            <td>
              <span :style="{ color: planMark[ind] !== undefined && planMark[ind].paymentMoneyMark ? '#e6a23c' : planMarkId.includes(v.id) ? '#8bc34a' : '' }">
                {{ moneyFormat(v.paymentMoney, 'w') }}
              </span>
            </td>
            <!--
            <td>
              <span :style="{ color: planMark[ind] !== undefined && planMark[ind].remarkMark ? '#e6a23c' : planMarkId.includes(v.id) ? '#8bc34a' : '' }">
                {{ translateCurrency(v.currency) }}
              </span>
            </td>
            -->
            <td>
              <span :style="{ color: planMark[ind] !== undefined && planMark[ind].remarkMark ? '#e6a23c' : planMarkId.includes(v.id) ? '#8bc34a' : '' }">
                {{ v.remark }}
              </span>
            </td>
          </tr>
        </tbody>
      </table>
    </div>

    <!-- 付款计划 -->
    <div v-if="form.dealContractPlanSpoList && form.dealContractPlanSpoList.length > 0" v-show="nameReceiptPayment === '收款' && (form.isPayment === 'collection')" style="margin-bottom: 20px;">
      <div class="area-header">
        <span class="area-header-title">{{ $t(nameReceiptPayment) }}{{ $t('计划') }}</span>
      </div>
      <table class="previewTable">
        <thead>
          <th>{{ $t('主体名称') }}</th>
          <th>{{ $t('预计收款时间') }}</th>
          <th>{{ $t('预计收款金额') }} {{ $t('金额单位') }}</th>
          <th>{{ $t('备注') }}</th>
        </thead>
        <tbody>
          <tr v-for="(v, ind) in form.dealContractPlanSpoList" :key="ind">
            <td>
              {{ selectDictLabel(dealContractPlanInvestMainOptions, v.investId) }}
            </td>
            <td>
              <span :style="{ color: planMark[ind] !== undefined && planMark[ind].collectionTimeMark ? '#e6a23c' : planMarkId.includes(v.id) ? '#8bc34a' : '' }">
                {{ parseTime(v.collectionTime) }}
              </span>
            </td>
            <td>
              <span :style="{ color: planMark[ind] !== undefined && planMark[ind].collectionMoneyMark ? '#e6a23c' : planMarkId.includes(v.id) ? '#8bc34a' : '' }">
                {{ moneyFormat(v.collectionMoney, 'w') }}
              </span>
            </td>
            <td>
              <span :style="{ color: planMark[ind] !== undefined && planMark[ind].remarkMark ? '#e6a23c' : planMarkId.includes(v.id) ? '#8bc34a' : '' }">
                {{ v.remark }}
              </span>
            </td>
          </tr>
        </tbody>
      </table>

    </div>

    <!-- 合同关键条款 -->
    <div style="margin-bottom: 20px;">
      <div class="area-header">
        <span class="area-header-title">{{ $t('合同关键条款') }}</span>
      </div>
      <table class="previewTable">
        <thead>
          <th>{{ $t('条款类型') }}</th>
          <th>{{ $t('条款内容') }}</th>
          <th>{{ $t('提醒时间') }}</th>
          <th>{{ $t('提醒人') }}</th>
        </thead>
        <tbody>
          <tr v-for="(v, ind) in form.dealContractTermsSpoList" :key="ind">
            <td>
              <span :class="termsMark[ind] !== undefined && termsMark[ind].typeMark ? 'markDifferent' : termsMarkId.includes(v.id) ? 'markDifferentNew' : ''">
                {{ v.typeLabel }}
              </span>
            </td>
            <td>
              <span :style="{ color: termsMark[ind] !== undefined && termsMark[ind].remarkMark ? '#e6a23c' : termsMarkId.includes(v.id) ? '#8bc34a' : '' }">
                {{ v.remark }}
              </span>
            </td>
            <td>
              <span :style="{ color: termsMark[ind] !== undefined && termsMark[ind].remindTimeMark ? '#e6a23c' : termsMarkId.includes(v.id) ? '#8bc34a' : '' }">
                {{ parseTime(v.remindTime) }}
              </span>
            </td>
            <td>
              <span :style="{ color: termsMark[ind] !== undefined && termsMark[ind].userNameMark ? '#e6a23c' : termsMarkId.includes(v.id) ? '#8bc34a' : '' }">
                {{ v.userName }}
              </span>
            </td>
          </tr>
        </tbody>
      </table>
    </div>
    <!-- 附件列表 -->
    <FileView :list.sync="form.fileList" data-type="deal_contract" :business-id="this.$route.query.id" :btn-show="!otherBtnHide" />
  </div>
</template>

<script>
    import {
      getDealContractSpo,
      findInvestMain
    } from '@/api/deal/spo/dealContractSpo'
    import { getLpViewByMainBodyId } from '@/api/oa/contract/oaContract'
    import MainBodySelect from '@/components/MainBodySelect'
    import { findDealBaseSelect } from '@/api/base/deal/dealBase'
    export default {
        components: {
          MainBodySelect
        },
        data() {
            return {
                loading: false,
                dealContractPaymentLoading: false,
                // 单选
                isSealOptions: [],
                isPaymentOptions: [],
                // 币种
                currencyOptions: [],
                // 表单参数
                form: {},
                // 是否隐藏保存按钮
                btnHide: false,
                // 是否隐藏其它按钮
                otherBtnHide: false,

                // 操作按钮默认不展示
                buttonShow: true,
                getTypeDict: [],
                uploaderOpen: false,
                dataType: 'deal_contract',
                title: '',
                isShowDeal: undefined,
                dealBaseOptions: [],
                sealTypeDict: undefined,
                // 收款  付款 名称
                nameReceiptPayment: '',
                // 是否展示最新持股比例
                isShowStake: false,
                dealContractPlanInvestMainOptions: [],
                dealContractPlanInvestMainOptionsTemp: [],
                // 新旧合同提示标识
                promptLogo: false,
                // 突出不同字段
                mark: {},
                // 用印标记
                sealMark: {},
                sealMarkId: [],
                // 主体标记
                investorMark: [],
                investorMarkId: [],
                // 收付款计划
                planMark: [],
                planMarkId: [],
                // 关键条款标记
                termsMark: [],
                termsMarkId: [],
                // 附件标记
                fileMark: [],
                relatedConvertibleBondContractDict: []
            }
        },
        watch: {
          'form.isPayment': {
            handler(val) {
              if (val === 'collection') {
                this.nameReceiptPayment = '收款'
              } else if (val === 'payment') {
                this.nameReceiptPayment = '付款'
              } else {
                this.nameReceiptPayment = '收付款'
              }
              if ((this.form.type === 'TZXY' || this.form.type === 'KZZXYTZ' || this.form.type === 'KZZTZXY') && val === 'payment') {
                this.isShowStake = true
              } else {
                this.isShowStake = false
              }
            }
          },
          'form.type': {
            handler(val) {
              if ((val === 'TZXY' || this.form.type === 'KZZXYTZ' || this.form.type === 'KZZTZXY') && this.form.isPayment === 'payment') {
                this.isShowStake = true
              } else {
                this.isShowStake = false
              }
            }
          }
        },
        created() {
            this.$bus.$emit('async_done')
            this.getDicts('sys_yes_no').then(response => {
              this.isSealOptions = response.data
            })
            this.getDicts('deal_contract_bond_equity').then(res => {
              this.getTypeDict = res.data
              if (this.getTypeDict === undefined || this.getTypeDict === null) {
                this.getTypeDict = []
              }
              this.getDicts('deal_contract_type_select').then(response => {
                response.data.forEach(item => {
                  this.getTypeDict.push(item)
                })
              })
            })
            this.getDicts('payment_no_deal').then(response => {
              this.isPaymentOptions = response.data
            })
            this.getDicts('seal_type').then(response => {
              this.sealTypeDict = response.data
            })
            this.getDicts('currency').then(response => {
              this.currencyOptions = response.data
            })
        },
        methods: {
          formatSeal(val) {
            return this.selectDictLabel(this.isSealOptions, val)
          },
          formatPayment(val) {
            return this.selectDictLabel(this.isPaymentOptions, val)
          },
          // 初始化数据
          init(data) {
            this.promptLogo = undefined
            this.changeContractBtnStatus = false
            this.initForm(data, () => {})
          },
          // 初始化数据
          initForm(data, callback) {
            if (this.$route.query.id === undefined || this.$route.query.id === null || this.$route.query.id === '') {
              this.isShowDeal = 'hidden'
              findDealBaseSelect().then(response => {
                this.dealBaseOptions = response.data
              })
            }
            if (data != null && data.id !== undefined && data.id !== '' && data.id !== null) {
              this.loading = true
              getDealContractSpo(data.id).then(response => {
                this.form = response.data
                this.form.isPayment = response.data.isPayment
                this.dealContractPlanInvestMainOptions = []
                this.loadingPlanName()
                // 和同比对
                if (typeof this.$parent.$parent.$parent.parentContractData === 'function') {
                  this.$parent.$parent.$parent.parentContractData(this.form)
                }
                callback()
                this.loading = false
              })
            } else {
              this.reset()
              if (data !== null) {
                // 默认带出流程中必须要传的附件
                this.form.fileList = data.fileList
              }
              // this.form.isPayment = ''
              // 签约主体带入默认值
              this.dealContractPaymentLoading = true
              findInvestMain(this.$route.query.id).then(response => {
                this.form.dealContractPaymentSpoList = response.data
                this.form.oaSealDetailList = []
                response.data.forEach(item => {
                  var row = {
                    investMain: item.investMain,
                    investMainType: item.investType
                  }
                  this.$nextTick(() => {
                    this.form.oaSealDetailList.push(row)
                  })
                })
                this.dealContractPlanInvestMainOptions = []
                this.loadingPlanName()
                callback()
                this.dealContractPaymentLoading = false
              })

              this.form.isPayment = 'no'
            }
          },
          // 加载付款计划主题名称
          loadingPlanName() {
            this.form.dealContractPaymentSpoList.forEach(item => {
              if (item.investMain !== null && item.investMain !== undefined && item.investMain !== '') {
                getLpViewByMainBodyId(item.investMain).then(response => {
                  if (response.data !== null) {
                    var temp = { dictValue: response.data.id, dictLabel: response.data.name }
                    this.dealContractPlanInvestMainOptions.push(temp)
                    this.dealContractPlanInvestMainOptionsTemp.push(temp)
                  }
                })
              }
            })
          },
          // 表单重置
          reset() {
            this.form = {
            id: undefined,
            applyUserId: this.$store.state.user.userId,
            dealId: this.$route.query.id,
            applyTime: new Date(),
            signingTime: undefined,
            name: undefined,
            money: 0,
            type: undefined,
            company: undefined,
            projectOrFund: undefined,
            isPayment: undefined,
            useSealOne: undefined,
            useSealTwo: undefined,
            payCompletionTime: undefined,
            abstracts: undefined,
            createBy: undefined,
            updateBy: undefined,
            createTime: undefined,
            updateTime: undefined,
            fileList: [],
            delFlag: undefined,
            oaSealDetailList: undefined
            }
            this.resetForm('form')
            this.dealContractPlanInvestMainOptions = []
          },

          // 自动计算预计付款金额 或 预计收款金额
          sumMoneyPayColl(type) {
            if (this.form.dealContractPlanSpoList !== null && this.form.dealContractPlanSpoList !== undefined) {
              var temp = 0
              // 付款
              if (type === 'payment') {
                this.form.dealContractPlanSpoList.forEach(item => {
                  item.collectionMoney = null
                  item.collectionTime = null
                  temp += parseInt(item.paymentMoney === undefined ? 0 : item.paymentMoney)
                })
              }
              // 收款
              if (type === 'collection') {
                this.form.dealContractPlanSpoList.forEach(item => {
                  item.paymentMoney = null
                  item.paymentTime = null
                  temp += parseInt(item.collectionMoney === undefined ? 0 : item.collectionMoney)
                })
              }
              this.form.money = temp
            }
          },
          changeIsPay(type) {
            this.sumMoneyPayColl(type)
          },
          changeInvestData(svalue, name) {
            var flagAddPlan = true
            var tempCount = 0
            // 签约主体中是否存在重复
            var tempPay = this.form.dealContractPaymentSpoList
            for (var i = 0; i < tempPay.length; i++) {
              if (tempPay[i].investMain === svalue) {
                tempCount++
                if (tempCount > 1) {
                  this.msgError(this.$t('签约主体存在重复'))
                  const row = {
                    investMainType: tempPay.investType,
                    investMain: ''
                  }
                  if (!(this.form.dealContractPaymentSpoList instanceof Array)) {
                    this.$set(this.form, 'dealContractPaymentSpoList', '')
                  }
                  this.$nextTick(() => {
                    this.form.dealContractPaymentSpoList.push(row)
                  })
                  // 删掉
                  this.form.dealContractPaymentSpoList.splice(i, 1)
                  flagAddPlan = false
                }
              }
            }
            // 收款计划 添加下拉元素
            if (flagAddPlan) {
              if (name !== undefined && svalue !== undefined) {
                var temp = {
                  dictLabel: name,
                  dictValue: svalue
                }
                this.dealContractPlanInvestMainOptionsTemp.push(temp)
              }
            }
            // 整理最终结果
            this.dealContractPlanInvestMainOptions = []
            this.dealContractPlanInvestMainOptionsTemp = this.toRepeatOption(this.dealContractPlanInvestMainOptionsTemp)
            var planOptionsArr = this.dealContractPlanInvestMainOptionsTemp
            tempPay.forEach(item => {
              planOptionsArr.forEach(itemPlan => {
                if (itemPlan.dictValue === item.investMain) {
                  this.dealContractPlanInvestMainOptions.push(itemPlan)
                }
              })
            })
            this.dealContractPlanInvestMainOptions = this.toRepeatOption(this.dealContractPlanInvestMainOptions)
          },
          // 数组去重复
          toRepeatOption(arr) {
            var hash = {}
            return arr.reduce(function(item, next) {
              hash[next.dictValue] ? '' : hash[next.dictValue] = true && item.push(next)
              return item
            }, [])
          },
          checkStake(val, index) {
            if (val !== null && val !== '' && val !== undefined) {
              if (val > 100) {
                this.form.dealContractPaymentSpoList[index].stake = ''
              }
            }
          },
          changeIsPayment() {
            if (this.form.type === 'TZXY' || this.form.type === 'BCXY') {
              this.form.isPayment = 'payment'
              this.isShowStake = true
            } else {
              this.form.isPayment = 'no'
              this.isShowStake = false
            }
          },
          // 字段合同差异标识
          contractDifferencesMark(data) {
            if (data !== null && data !== undefined) {
              this.mark = data.form
              // 用印
              var sealMarkArr = []
              if (this.form.oaSealDetailList !== undefined && this.form.oaSealDetailList !== null && data.sealDetail !== undefined && data.sealDetail !== null) {
                this.form.oaSealDetailList.forEach(item => {
                  var flag = true
                  data.sealDetail.forEach(item2 => {
                    if (item.id === item2.id) {
                      sealMarkArr.push(item2)
                      flag = false
                    }
                  })
                  if (flag) {
                    sealMarkArr.push(undefined)
                  }
                })
              }
              this.sealMark = sealMarkArr

              this.sealMarkId = []
              this.sealMark.forEach(item => {
                if (item !== undefined) {
                  this.sealMarkId.push(item.id)
                }
              })
              // 取差集, 获取当前页面里存在但是 后台回来的Id中不存在,这行数据, 就是新增的
              const sealMarkArr1 = this.sealMarkId
              const sealMarkArr2 = this.form.oaSealDetailList === null ? [] : this.form.oaSealDetailList
              var tempSealMarkArr2 = []
              sealMarkArr2.forEach(item => {
                tempSealMarkArr2.push(item.id)
              })
              var sealSet1 = new Set(sealMarkArr1)
              var sealSet2 = new Set(tempSealMarkArr2)
              this.sealMarkId = Array.from(new Set(sealMarkArr1.concat(tempSealMarkArr2).filter(v => !sealSet1.has(v) || !sealSet2.has(v))))
              console.log('用印差集', this.sealMarkId, this.sealMark)

              // 签约主体
              var investorMarkArr = []
              if (this.form.dealContractPaymentSpoList !== undefined && this.form.dealContractPaymentSpoList !== null && data.investor !== undefined && data.investor !== null) {
                this.form.dealContractPaymentSpoList.forEach((item) => {
                  var flag = true
                  data.investor.forEach(item2 => {
                    if (item.id === item2.id) {
                      investorMarkArr.push(item2)
                      flag = false
                    }
                  })
                  if (flag) {
                    investorMarkArr.push(undefined)
                  }
                })
              }
              this.investorMark = investorMarkArr

              this.investorMarkId = []
              this.investorMark.forEach(item => {
                if (item !== undefined) {
                  this.investorMarkId.push(item.id)
                }
              })
              // 取差集, 获取当前页面里存在但是 后台回来的Id中不存在,这行数据, 就是新增的
              const investorMarkArr1 = this.investorMarkId
              const investorMarkArr2 = this.form.dealContractPaymentSpoList === null ? [] : this.form.dealContractPaymentSpoList
              var tempInvestorMarkArr2 = []
              investorMarkArr2.forEach(item => {
                tempInvestorMarkArr2.push(item.id)
              })
              var InvestorSet1 = new Set(investorMarkArr1)
              var InvestorSet2 = new Set(tempInvestorMarkArr2)
              this.investorMarkId = Array.from(new Set(investorMarkArr1.concat(tempInvestorMarkArr2).filter(v => !InvestorSet1.has(v) || !InvestorSet2.has(v))))
              console.log('主体差集', this.investorMarkId, this.investorMark)

              // 付款计划
              var planMarkArr = []
              if (this.form.dealContractPlanSpoList !== undefined && this.form.dealContractPlanSpoList !== null && data.plan !== undefined && data.plan !== null) {
                this.form.dealContractPlanSpoList.forEach((item) => {
                  var flag = true
                  data.plan.forEach(item2 => {
                    if (item.id === item2.id) {
                      planMarkArr.push(item2)
                      flag = false
                    }
                  })
                  if (flag) {
                    planMarkArr.push(undefined)
                  }
                })
              }
              this.planMark = planMarkArr
              this.planMarkId = []
              this.planMark.forEach(item => {
                if (item !== undefined) {
                  this.planMarkId.push(item.id)
                }
              })
              // 取差集, 获取当前页面里存在但是 后台回来的Id中不存在,这行数据, 就是新增的
              const planMarkArr1 = this.planMarkId
              const planMarkArr2 = this.form.dealContractPlanSpoList === null ? [] : this.form.dealContractPlanSpoList
              var tempMarkArr2 = []
              planMarkArr2.forEach(item => {
                tempMarkArr2.push(item.id)
              })
              var planSet1 = new Set(planMarkArr1)
              var planSet2 = new Set(tempMarkArr2)
              this.planMarkId = Array.from(new Set(planMarkArr1.concat(tempMarkArr2).filter(v => !planSet1.has(v) || !planSet2.has(v))))
              // console.log('收付款计划差集', this.planMarkId)

              // 关键条款
              var termsMarkArr = []
              if (this.form.dealContractTermsSpoList !== undefined && this.form.dealContractTermsSpoList !== null && data.terms !== undefined && data.terms !== null) {
                this.form.dealContractTermsSpoList.forEach(item => {
                  var flag = true
                  data.terms.forEach(item2 => {
                    if (item.id === item2.id) {
                      termsMarkArr.push(item2)
                      flag = false
                    }
                  })
                  if (flag) {
                    termsMarkArr.push(undefined)
                  }
                })
              }
              this.termsMark = termsMarkArr
              this.termsMarkId = []
              this.termsMark.forEach(item => {
                if (item !== undefined) {
                  this.termsMarkId.push(item.id)
                }
              })
              // 取差集, 获取当前页面里存在但是 后台回来的Id中不存在,这行数据, 就是新增的
              const termsMarkArr1 = this.termsMarkId
              const formTerms = this.form.dealContractTermsSpoList === null ? [] : this.form.dealContractTermsSpoList
              var termsMarkArr2 = []
              formTerms.forEach(item => {
                termsMarkArr2.push(item.id)
              })
              var aSet = new Set(termsMarkArr1)
              var bSet = new Set(termsMarkArr2)
              this.termsMarkId = Array.from(new Set(termsMarkArr1.concat(termsMarkArr2).filter(v => !aSet.has(v) || !bSet.has(v))))
              // console.log('关键条款差集', this.termsMarkId)

              // 附件
              var fileMarkArr = []
              if (this.form.fileList !== undefined && this.form.fileList !== null && data.fileList !== undefined && data.fileList !== null) {
                var flag = true
                this.form.fileList.forEach(item => {
                  flag = true
                  data.fileList.forEach(item2 => {
                    if (item.name === item2.name) {
                      fileMarkArr.push(item2)
                      flag = false
                    }
                  })
                  if (flag) {
                    fileMarkArr.push(undefined)
                  }
                })
              }
              this.fileMark = fileMarkArr
            }
          },
          translateCurrency(row) {
            return this.selectDictLabel(this.currencyOptions, row)
          }
        }
    }
</script>
<style scoped>
  .splitter-pane.vertical.splitter-paneR[data-v-815c801c] {
    background-color: white;
  }
  .markDifferent {
    color: #e6a23c;
  }
  .markDifferentNew {
    color: #8bc34a;
  }
  .markDifferent >>> input {
    color: #e6a23c;
  }
  .markDifferentNew >>> input {
    color: #8bc34a;
  }
  .markDifferent_radio >>> .el-radio__input.is-checked .el-radio__inner {
    background-color: #e6a23c;
    border-color: #e6a23c;
  }
  .markMain >>> .el-input--medium .el-input__inner {
    color: #e6a23c;
  }
  .selectMoreMark >>> .el-tag.el-tag--info {
    color: #e6a23c;
  }
  .selectMoreMarkNew >>> .el-tag.el-tag--info {
    color: #8bc34a;
  }
  .promptLogoClass {
    border-radius: 7px;
    border: 1px solid #1890ff;
    padding: 5px 20px 5px 20px;
    background: #1890ff;
    color: white;
  }
</style>
